import time

from selenium import webdriver
from  Test.unit_03.Base import Base
from selenium.webdriver.common.by import By

class Page(Base):
    # 定位元素
    # 1 点击请登录
    login_loc = (By.XPATH, '/html/body/div[2]/div/div[1]/div/a[1]')

    def login(self):
        print(self.get_text(self.login_loc))
        self.click(self.login_loc)

    # 输入账号
    userName_loc = (By.ID, 'userName')
    def userName(self):
        self.send_keys(self.userName_loc,'19831651709')

    # 输入密码
    password_loc = (By.ID, 'password')
    def password(self):
        self.send_keys(self.password_loc, '123456aA')

    # 点击登陆按钮
    save_loc = (By.ID, 'save')
    def save(self):
        self.click(self.save_loc)
    # 点击确定按钮
    right_loc = (By.XPATH, '//*[@id="bindSub"]')
    def right(self):
        self.click(self.right_loc)

    def jiuxian_luoji(self):
        self.openurl('https://www.jiuxian.com/')
        self.login()
        self.userName()
        time.sleep(2)
        self.password()
        time.sleep(20)
        self.save()
        time.sleep(2)
        self.right()
